<?php
class Formatter extends CFormatter {

    public $currencySymbol;
    public $countryCode;

    public function formatCurrency($value, $currencySymbol = null) {
        return Yii::app()->numberFormatter->formatCurrency(empty($value) ? 0 : $value, empty($currencySymbol)? $this->currencySymbol: $currencySymbol);
        //return Yii::app()->numberFormatter->formatCurrency(empty($value) || $value < 0 ? $defaultValue : $value, $this->currencySymbol);
    }//end function

    public function formatNumericOnly($value, $delimiter = '') {
        preg_match("|\d+|", $string, $matches);
        return implode($delimiter, $matches);
    }

    public function formatAlphaNumericOnly($value, $delimiter = ' ') {
        $arr = explode(' ', preg_replace("/([^A-Za-z0-9 ])+/", ' ', $value));
        return implode($delimiter, array_filter($arr));
    }

    public function formatKeyword($value, $delimiter = ' ') {
        $arr = explode(' ', preg_replace("/([^A-Za-z0-9# ])+/", ' ', $value));
        return implode($delimiter, array_filter($arr));
    }
    
    public function formatUrlText($value) {
        //return strtolower($this->alphaNumericOnly($value, '-'));
        return Helper::url_slug($value);
    }

}//end class
